extends Node2D

@onready var Anima: AnimationPlayer = $AnimationPlayer
@onready var gun: Node2D = $gun

#预加载弹幕场景
var bullet: PackedScene = preload("res://Scenes/core_attack.tscn")


#设置变量
var relative_position: Vector2 # 与鼠标相对向量
var cool_down_time: float = 0.25

func _ready() -> void:
	Anima.play("ready")
	Global.core_position = global_position
	Global.mouse_left.connect(self.shoot)

# 简化后的冷却机制
var cool_down_done: bool = true

func _process(delta: float) -> void:
	pass

func shoot() -> void:
	if cool_down_done:
		var b = bullet.instantiate()
		gun.add_child(b)
		b.global_position = gun.global_position
		b._spawn_ready()
		start_cooldown()

func start_cooldown() -> void:
	cool_down_done = false
	await get_tree().create_timer(cool_down_time).timeout
	cool_down_done = true
